<?php
require_once(dirname(dirname(dirname(__FILE__))) . '/app.php');

need_manager(true);

$constellations = array(
	'1' => '水瓶座',
	'2' => '双鱼座',
	'3' => '白羊座',
	'4' => '金牛座',
	'5' => '双子座',
	'6' => '巨蟹座',
	'7' => '狮子座',
	'8' => '处女座',
	'9' => '天枰座',
	'10' => '天蝎座',
	'11' => '射手座',
	'12' => '摩羯座',
);

$degrees = array(
	'1' => '本科',
	'2' => '硕士',
	'3' => '博士',
	'4' => '其他',
);


if ($_POST) {
	$guest = $_POST;
//	print_r($_POST);
	$insert = array(
		'user_id', 'name', 'mobile', 'email', 'title', 'summary', 'age', 'gender', 'height', 'weight', 'constellation', 'degree', 
		'career', 'resident', 'hometown', 'salary', 'hobby', 'detail', 'image', 'image1', 'image2', 'image3', 'vcr', 'judge', 
		'begin_time', 'end_time', 'now_number', 'system','status',
		);
	
	$guest['user_id'] = $login_user_id;
	$guest['begin_time'] = strtotime($guest['begin_time']);
	$guest['constellation'] = abs(intval($guest['city_id']));
	$guest['end_time'] = strtotime($guest['end_time']);
//	$guest['expire_time'] = strtotime($guest['expire_time']);
//	$guest['pre_number'] = abs(intval($guest['pre_number']));
//	$guest['now_number'] = 0;
	$guest['image'] = upload_image('image', null, 'guest');
	$guest['image1'] = upload_image('image1', null, 'guest');
	$guest['image2'] = upload_image('image2', null, 'guest');
	$guest['image3'] = upload_image('image3', null, 'guest');
	$guest['vcr'] = upload_vcr('vcr', null, 'guest');
	
	$table = new Table('guest', $guest);
		
	$table->SetStrip('detail', 'judge', 'summary');
	if ( $guest_id = $table->insert($insert) ) {
		redirect( WEB_ROOT . "/manage/guest/index.php");
	}
}
else {
		
	$guest = array();
	$guest['user_id'] = $login_user_id;
	$guest['begin_time'] = strtotime('+1 days');
	$guest['end_time'] = strtotime('+2 days'); 
}

/*
$groups = DB::LimitQuery('category', array(
			'condition' => array( 'zone' => 'group', ),
			));
$groups = Utility::OptionArray($groups, 'id', 'name');

$partners = DB::LimitQuery('partner', array(
			'order' => 'ORDER BY id DESC',
			));
$partners = Utility::OptionArray($partners, 'id', 'title');
*/
$selector = 'create';
include template('manage_guest_create');
